home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / ViewKit_dev.idb / usr / include / Vk / VkNameList.h.z / VkNameList.h
Encoding:
C/C++ Source or Header  |  1996-09-20  |  4.1 KB  |  114 lines

  1.  
  2. ////////////////////////////////////////////////////////////////////////////////
  3. ///////   Copyright 1992, Silicon Graphics, Inc.  All Rights Reserved.   ///////
  4. //                                                                            //
  5. // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;     //
  6. // the contents of this file may not be disclosed to third parties, copied    //
  7. // or duplicated in any form, in whole or in part, without the prior written  //
  8. // permission of Silicon Graphics, Inc.                                       //
  9. //                                                                            //
  10. // RESTRICTED RIGHTS LEGEND:                                                  //
  11. // Use,duplication or disclosure by the Government is subject to restrictions //
  12. // as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data     //
  13. // and Computer Software clause at DFARS 252.227-7013, and/or in similar or   //
  14. // successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -    //
  15. // rights reserved under the Copyright Laws of the United States.             //
  16. //                                                                            //
  17. ////////////////////////////////////////////////////////////////////////////////
  18.  
  19. //////////////////////////////////////////////////////////////////////////////
  20. //
  21. //    VkNameList Class Definition 
  22. //
  23. //
  24. //////////////////////////////////////////////////////////////////////////////
  25.  
  26. #ifndef VKNAMELIST_H
  27. #define VKNAMELIST_H
  28.  
  29. #include <Xm/Xm.h>
  30.  
  31. void FreeIdTable (char**);
  32.  
  33. class VkNameList {
  34.  
  35.     public:
  36.  
  37.     VkNameList ();
  38.     VkNameList (const VkNameList&);
  39.     VkNameList (char*);
  40.     ~VkNameList ();
  41.  
  42.     void clear    ();
  43.  
  44.     void add    (char*);                 // dups input
  45.     void add    (const VkNameList&);         // dups input
  46.         void addCommaSeparated (const char* list);   // dups input
  47.  
  48.     // Would like the following to be "remove (char*, int=1), but that
  49.     // would change the signature, causing binary compatibility
  50.     // problems.  You can get the same effect by
  51.     //    "remove (getIndex (char*), int=1)"
  52.     void remove    (char*);
  53.     void remove    (int, int count=1);    // Remove several strings
  54.     int getIndex    (const char *) const;    // Locate a string in the list
  55.  
  56.     void sort    ();        // uses qsort
  57.         void reverse    ();
  58.     void removeDuplicates ();
  59.  
  60.     int  size   () const { return _size; }
  61.     int  exists (char*) const;    // returns 1 if char* matches atleast
  62.                     // 1 item in the list.
  63.  
  64.     VkNameList&  operator=       (const VkNameList&);
  65.     int         operator==       (const VkNameList&) const;
  66.  
  67.     // The following operators are problematical, because the allocate
  68.     // storage that must be freed.  It is better to use the equivalent
  69.     /// "getXxxxx" function, because then the need to free is clear.
  70.     //
  71.     char*         operator[]       (int index)        const;
  72.     char*         getString       (int index)        const;
  73.  
  74.     VkNameList   operator[]       (char *subString)    const;
  75.     VkNameList*  getSubstrings (char *subString)    const;
  76.  
  77.     operator     char**       ()            const;
  78.     char**         getStringTable()            const;
  79.  
  80.     operator     XmStringTable ()            const;
  81.     XmStringTable getXmStringTable()        const;
  82.     static void  freeXmStringTable (XmStringTable);
  83.  
  84.  
  85.  
  86.     char*     mostCommonString () const;
  87.  
  88.     virtual VkNameList* completeName (char* name, char*& completedName, int& nMatching);
  89.     // attempt to complete <name>
  90.     //
  91.     //----------------------------------------------------------------------
  92.     // condition        return val    completedName         nMatching
  93.     //----------------------------------------------------------------------
  94.     // no match        null list     longest sub-string    0
  95.     //                      matching at least one 
  96.     //----------------------------------------------------------------------
  97.     // more than one    all those     most common string    # of matches
  98.     // match        who match     among the matched
  99.     //
  100.     //----------------------------------------------------------------------
  101.     // exactly one match    matched          copy of matched        1
  102.     //            (completed)   string
  103.     //            string
  104.     //----------------------------------------------------------------------
  105.  
  106.     private:
  107.  
  108.     char**    _names;
  109.     int    _size;
  110.  
  111. };
  112.  
  113. #endif /* VKNAMELIST_H */
  114.